<?php

class Truck_exam extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'Truck_exam':
	 * @var integer $id
	 * @var string $plate_no
	 * @var string $main_driver_name
	 * @var string $type_name
	 * @var double $to_income
	 * @var double $salary
	 * @var double $gas_fee
	 * @var double $bridge_charge
	 * @var double $maintain_fee
	 * @var double $repair_fee
	 * @var double $amerce_fee
	 * @var double $reparation
	 * @var double $other_fee
	 * @var double $depreciation
	 * @var double $insure_fee
	 * @var double $managing_cost
	 * @var double $salary_cost
	 * @var double $gps_fee
	 * @var double $root_cost
	 * @var double $total_cost
	 * @var double $profit
	 * @var string $merit_pay_kind
	 * @var double $merit_pay
	 * @var double $merit_pay_ratio
	 * @var double $actual_salary
	 * @var string $truck_kind
	 * @var double $gas_ratio
	 * @var double $bridge_ratio
	 * @var double $rapair_ratio
	 * @var double $amerce_ratio
	 * @var double $other_ratio
	 * @var double $profit_ratio
	 * @var integer $stat_region
	 * @var string $stat_date
	 * @var integer $state
	 * @var string $create_time
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'truck_exam';
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => '索引号',
			'plate_no' => '车牌号',
			'main_driver_name' => '主司机',
			'type_name' => '车型',
			'to_income' => '营运收入',
			'salary' => '人员工资',
			'gas_fee' => '油费',
			'bridge_charge' => '路桥费',
			'maintain_fee' => '保养费',
			'repair_fee' => '修理费',
			'amerce_fee' => '罚款',
			'reparation' => '事故赔偿',
			'other_fee' => '其他费用',
			'depreciation' => '折旧费',
			'insure_fee' => '保险费',
			'managing_cost' => '管理成本',
			'salary_cost' => '工资性支出',
			'gps_fee' => 'gps费',
			'mm_cost' => '营运强制保养',
			'avi_cost' => '车辆年审',
			'gi_cost' => '营运等级鉴定',
			'root_cost' => '固定费合计',
			'total_cost' => '费用合计',
			'profit' => '单车利润',
			'merit_pay_kind' => '档次',
			'merit_pay' => '绩效工资',
			'merit_pay_ratio' => '核算系数',
			'actual_salary' => '实发工资',
			'truck_kind' => '车类',
			'gas_ratio' => '油耗占比',
			'bridge_ratio' => '路桥占比',
			'rapair_ratio' => '修理占比',
			'amerce_ratio' => '罚款占比',
			'other_ratio' => '其他占比',
			'profit_ratio' => '利润占比',
			'stat_region' => '统计区间',
			'stat_date' => '统计时间',
			'state' => '状态',
			'create_time' => '创建时间',
		);
	}
	
	public function excelAttributes(){//导出excel所需的字段名、列号、宽度 merge:合并单元格 sum:合计
		return array(
			'plate_no'=>array('B',10,'merge'=>'true'),
			'main_driver_name'=>array('C',10,'merge'=>'true'),
			'type_name'=>array('D',20,'merge'=>'true'),
			'to_income'=>array('E',10,'sum'=>true,'merge'=>'true'),
			'salary'=>array('F',10,'sum'=>true),
			'gas_fee'=>array('G',10,'sum'=>true),
			'bridge_charge'=>array('H',10,'sum'=>true),
			'maintain_fee'=>array('I',10,'sum'=>true),
			'repair_fee'=>array('J',10,'sum'=>true),
			'amerce_fee'=>array('K',10,'sum'=>true),
			'reparation'=>array('L',10,'sum'=>true),
			'other_fee'=>array('M',10,'sum'=>true),
			'depreciation'=>array('N',10,'sum'=>true),
			'insure_fee'=>array('O',10,'sum'=>true),
			'managing_cost'=>array('P',10,'sum'=>true),
			'salary_cost'=>array('Q',12,'sum'=>true),
			'gps_fee'=>array('R',10,'sum'=>true),
			'mm_cost' =>array('S',14,'sum'=>true),
			'gi_cost' =>array('T',14,'sum'=>true),
			'avi_cost' =>array('U',10,'sum'=>true),
			'root_cost'=>array('V',14,'sum'=>true,'merge'=>'true'),
			'total_cost'=>array('W',10,'sum'=>true,'merge'=>'true'),
			'profit'=>array('X',10,'sum'=>true,'merge'=>'true'),
			'merit_pay_kind'=>array('Y',10,'merge'=>'true'),
			'merit_pay'=>array('Z',10,'sum'=>true,'merge'=>'true'),
			'merit_pay_ratio'=>array('AA',10,'merge'=>'true'),
			'actual_salary'=>array('AB',10,'sum'=>true,'merge'=>'true'),
			'truck_kind'=>array('AC',10,'merge'=>'true'),
			'gas_ratio'=>array('AD',10,'sum'=>'CONCAT(FORMAT(sum(gas_fee)/sum(to_income)*100,2),"%")','sum_excel'=>'G%/E%','merge'=>'true'),
			'bridge_ratio'=>array('AE',10,'sum'=>'CONCAT(FORMAT(sum(bridge_charge)/sum(to_income)*100,2),"%")','sum_excel'=>'H%/E%','merge'=>'true'),
			'rapair_ratio'=>array('AF',10,'sum'=>'CONCAT(FORMAT(sum(maintain_fee+repair_fee)/sum(to_income)*100,2),"%")','sum_excel'=>'(I%+J%)/E%','merge'=>'true'),
			'amerce_ratio'=>array('AG',10,'sum'=>'CONCAT(FORMAT(sum(amerce_fee)/sum(to_income)*100,2),"%")','sum_excel'=>'K%/E%','merge'=>'true'),
			'other_ratio'=>array('AH',10,'sum'=>'CONCAT(FORMAT(sum(other_fee)/sum(to_income)*100,2),"%")','sum_excel'=>'M%/E%','merge'=>'true'),
			'profit_ratio'=>array('AI',10,'sum'=>'CONCAT(FORMAT(sum(profit)/sum(to_income)*100,2),"%")','sum_excel'=>'X%/E%','merge'=>'true'),
			'stat_date'=>array('AJ',10,'merge'=>'true'),
		);
	}
}